import nprogress from "nprogress";

import { createRouter, createWebHashHistory } from "vue-router";
// 自己维护路由表
import { routers } from "./routers";

const router = createRouter({
  history: createWebHashHistory(),
  routes: routers,
});

router.beforeEach(async (to, from, next) => {
  nprogress.start();
  // 设置页面标题
  document.title = to.meta.title
  next();
});

// 路由加载后
router.afterEach(() => {
  nprogress.done();
});

router.onError((e) => {
  console.error("[ error router ] >", e)
})
export default router;
